﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Policy;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using text.Utils;

namespace text
{
    public partial class rizhi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnPublic_Click(object sender, EventArgs e)
        {
            string tittle=txttittle.Text.Trim();
            string detail = txtcontent.Text.Trim();
            DataRow userRow = (DataRow)Session["User"];
            int user_id = Convert.ToInt32(userRow["id"]);
            string sql = string.Format("insert into notes values('{0}','{1}',{2},'{3}',0)",tittle,detail,user_id, DateTime.Now);
            string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            SqlConnection conn1 = new SqlConnection(conn);
            SqlCommand cmd = new SqlCommand(sql, conn1);
            conn1.Open();
            int flag = cmd.ExecuteNonQuery();
            conn1.Close();
            if (flag > 0)
            {
                Response.Write("<script>alert('发布成功')</script>");
            }
        }
    }
}